package leecode.数组和字符串.旋转矩阵;

public class matrix {
    public static void main(String[] args) {
        int[][] matrix = new int[][]{{0,1,2},{3,4,5},{6,7,8}};

        int n=matrix.length;
        //对角线旋转
        for (int i = 0; i <n ; i++) {
            //从i开始
            for (int j = i + 1; j <n ; j++) {
                int t=matrix[i][j];
                matrix[i][j]=matrix[j][i];
                matrix[j][i]=t;
            }
        }
        //以中间 左右对称 旋转
        //右移1位
        int mid=n>>1;
        for (int i = 0; i <n ; i++) {
            for (int j = 0; j <mid ; j++) {
                int t=matrix[i][j];
                matrix[i][j]=matrix[i][n-j-1];
                matrix[i][n-j-1]=t;
            }
        }






    }




    }


